﻿Public Class frmMain
    Dim frm As Form
    Dim center As Form
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim frmDialog As New frmKetNoi()
        frmDialog.ShowDialog()
        If modKetNoi.strConnectionString = "" Then
            ' Đăng nhập ko thành công => đóng chương trình
            Me.Close()
        Else
            ' Đăng nhập thành công => hiển thị màn hình chính
            center = New frmCenter()
            center.StartPosition = FormStartPosition.CenterScreen
            center.Show()
            center.MdiParent = Me
            Me.stiKyHan.Text = modKetNoi.aryConfig("Thang") & "/" & modKetNoi.aryConfig("Nam")
            If modKetNoi.aryConfig("Locked") Then
                Me.stiLocked.Visible = True
            End If
        End If
    End Sub

    Private Sub mtsThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mtsThoat.Click
        Me.Close()
    End Sub

    Private Sub mtsTaiKhoan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mtsTaiKhoan.Click
        closeCurrentForm()
        frm = New frmTaiKhoanDs()
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.Show()
        frm.MdiParent = Me
    End Sub

    Private Sub mtsKhachHang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mtsKhachHang.Click
        closeCurrentForm()
        frm = New frmKhachHangDs()
        frm.StartPosition = FormStartPosition.CenterScreen 
        frm.Show()
        frm.MdiParent = Me
    End Sub

    Private Sub closeCurrentForm()
        If Not frm Is Nothing Then
            frm.Close()
        End If
    End Sub

    Private Sub mtsSetting_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mtsSetting.Click
        closeCurrentForm()
        frm = New frmThietLap(center)
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.Show()
        frm.MdiParent = Me
    End Sub

    Private Sub DanhMụcHàngHóaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DanhMụcHàngHóaToolStripMenuItem.Click
        closeCurrentForm()
        frm = New frmHangHoaDs()
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.Show()
        frm.MdiParent = Me
    End Sub

    Private Sub DanhSáchToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DanhSáchToolStripMenuItem.Click
        closeCurrentForm()
        frm = New frmSoCai()
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.Show()
        frm.MdiParent = Me
    End Sub

    Private Sub PhiếuNhậpKhoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PhiếuNhậpKhoToolStripMenuItem.Click
       
    End Sub
End Class